/*
** 1163.c
** 
** Made by (seakage2h)
** Login   <seakage2h@seakage2h-ubuntu>
** 
** Started on  Mon Sep 29 21:21:49 2008 seakage2h
** Last update Sun May 12 01:17:25 2002 Speed Blue
*/

/* #include "1163.h" */
#include <stdio.h>

int main()
{
     int tlv, clv;			/* total level, current level */
     int sum1[100], sum2[100], pnum[100]; /* sum:sum for each path
					 * pnum:the number on that position */
     int i;
     int *tmp_st, *cur, *swp;		/* tmp_st: temporarily store
					 * cur: currently processing */
     int max;
     
     for(i = 0; i < 100; i++)
	  sum1[i] = sum2[i] = pnum[i] = 0;
     
     scanf("%d", &tlv);
     /* INITIALIZATION in level 1 */
     scanf("%d", sum1);		/* scan into sum[0] */
     tlv--;
     tmp_st = sum1;
     cur = sum2;
     for(clv = 2; tlv > 0; tlv--, clv++){
	  for(i = 0; i < clv; i++) /* scan proper amount of nums into pnum[] */
	       scanf("%d", &pnum[i]);
	  cur[0] = tmp_st[0] + pnum[0];			  /* set up head */
	  cur[clv - 1] = tmp_st[clv - 2] + pnum[clv - 1]; /* set up tail */
	  for(i = 1; i < clv - 1; i++) /* store the larger sum */
	       if (pnum[i] + tmp_st[i - 1] > pnum[i] + tmp_st[i])
		    cur[i] = pnum[i] + tmp_st[i-1];
	       else cur[i] = pnum[i] + tmp_st[i];
	  swp = tmp_st;
	  tmp_st = cur;
	  cur = swp;
     }

     max = tmp_st[0];
     for(i = 1; i < clv; i++)
	  if (tmp_st[i] > max)
	       max = tmp_st[i];
     printf("%d", max);
     return 0;
}

